<script>
$(function(){
    $('#add').submit(function(){
        // ajax发送数据
        $.post(location.href,$(this).serialize()+'&type=add',function(data){
            if (data.state <= 0)
            {
                if(data.extra != '') $('#'+data.extra).focus();
                alert(data.message);
                return false;
            }
            $(data.message).appendTo('#receive_list');
        },'json');
        return false;
    });
    // 提交订单
    $('#list').submit(function(){
        $.post(location.href,$(this).serialize()+'&type=submitorder',function(data){
            alert(data.message);
            if (data.state <= 0)
            {
                return false;
            }
            else
            {
                window.location.href = '?app=<?php echo APP; ?>&mod=<?php echo MOD; ?>&r='+Math.random();
            }
        },'json');
        return false;
    });
});
</script>

<form id="list">
<div class="t_2">
     <div class="fl">提交订单</div>
     <div class="fr add_form"><a href="javascript:;" id="add_table"></a></div>
</div>
<div class="order_show" id="info_form"><table width="100%" cellpadding="0" cellspacing="0" border="0" class="info_table">
		<tr>
			<td class="td1" width="20%">选择收货地址：</td>
			<td colspan="6">
				<?php if($this->rlist): ?>
				<ul id="receive_list">
				<?php foreach ((array)$this->rlist as $item): ?>
					<li><input type="radio" name="rid" value="<?php echo $item['cr_id']; ?>" id="r<?php echo $item['cr_id']; ?>"/><label for="r<?php echo $item['cr_id']; ?>"><?php echo $item['address']; ?>&nbsp;&nbsp;<?php echo $item['receive_name']; ?>&nbsp;&nbsp;<?php echo $item['zip']; ?>&nbsp;&nbsp;<?php echo $item['tel']; ?></label></li>
				<?php endforeach; ?>
				<?php else: ?>
				当前客户没有收货地址
				<?php endif; ?>
				</ul>
			</td>
		</tr>
		<tr>
			<td class="td1" width="20%">发票信息：</td>
			<td colspan="6">
				<?php if($this->fapiaolist): ?>
				<ul>
				<?php foreach((array)$this->fapiaolist as $fapiao): ?>
					<li><input type="radio" name="fid" value="<?=$fapiao['fid']?>" id="f<?=$fapiao['fid']?>"/><label for="f<?=$fapiao['fid']?>"><?=$fapiao['name']?></label></li>
				<?php endforeach; ?>
				</ul>
				<?php else: ?>
				当前客户没有发票信息
				<?php endif ?>
			</td>
		</tr>
		<tr>
			<td class="td1" width="20%">合同类型：</td>
			<td colspan="6">
				<ul>
				<?php foreach ((array)$this->contract_list as $item): ?>
					<li><input type="radio" name="contract" value="<?php echo $item; ?>" id="r<?php echo $item; ?>"/><label for="r<?php echo $item; ?>"><?php echo $item; ?></label></li>
				<?php endforeach; ?>
				</ul>
			</td>
		</tr>
        <tr>
            <td width="20%" rowspan="5"  class="td1">合同信息：</td>
        </tr>
        <tr>
          <td>合同号：</td>
          <td colspan="5"><input type="text" name="contract_number" value=""/></td>
        </tr>
        <tr>
          <td>预付款时间：</td>
          <td><input type="text" name="price_content[1][time]" value="" onclick="new Calendar().show(this)" readonly="readonly"/></td>
          <td>预付款金额：</td>
          <td><input type="text" name="price_content[1][price]" value=""/></td>
          <td>预付百分比：</td>
          <td><input type="text" name="price_content[1][percent]" value=""/></td>
        </tr>
        <tr>
          <td>收获后付款时间：</td>
          <td><input type="text" name="price_content[2][time]" value="" onclick="new Calendar().show(this)" readonly="readonly"/></td>
          <td>收获后付款金额：</td>
          <td><input type="text" name="price_content[2][price]" value=""/></td>
          <td>收获后付款百分比：</td>
          <td><input type="text" name="price_content[2][percent]" value=""/></td>
        </tr>
        <tr>
          <td>尾款付款时间：</td>
          <td><input type="text" name="price_content[3][time]" value="" onclick="new Calendar().show(this)" readonly="readonly"/></td>
          <td>尾款付款金额：</td>
          <td><input type="text" name="price_content[3][price]" value=""/></td>
          <td>尾款付款百分比：</td>
          <td><input type="text" name="price_content[3][percent]" value=""/></td>
        </tr>
		<tr>
			<td class="td1" width="20%">下级受理人：</td>
			<td colspan="6">
				<select name="audit_member_id">
					<option>请选择</option>
					<?php foreach((array)$this->member_list as $item): ?>
					<option value="<?=$item['uid']?>"><?=$item['username']?>[<?=$item['nickname']?>]</option>
					<?php endforeach; ?>
				</select>
			</td>
		</tr>
		<tr>
			<td class="td1" width="20%">应付价/审批价：</td>
			<td colspan="6">￥<?=number_format($this->pprice,2)?></td>
		</tr>
		<tr>
			<td class="td1" style="text-align:center" colspan="7"><input name="" type="submit" class="btn1" value="提交订单" /><input name="" type="reset" class="btn1" value="重置" /><?php echo showhide(array_merge($_GET,array('step'=>4))); ?></td>
		</tr>
     </table>
</div>
</form>
<!-- 添加新的收货地址 -->
<form id="add">
<div class="t_2">
     <div class="fl">快速添加收货地址</div>
     <div class="fr add_form"><a href="javascript:;" id="add_table"></a></div>
</div>
<div class="order_show" id="info_form">
     <table width="100%" cellpadding="0" cellspacing="0" border="0" class="info_table">
		<tr>
			<td class="td1" width="20%">地址：</td>
			<td><input name="address" id="address" value="" /><font color="#848484">不超过300个字符</font></td>
		</tr>
		<tr>
			<td class="td1" width="20%">邮编：</td>
			<td><input name="zip" id="zip" value="" /><font color="#848484">6位纯数字</font></td>
		</tr>
		<tr>
			<td class="td1" width="20%">联系电话：</td>
			<td><input name="tel" id="tel" value="" /><font color="#848484">7或11位纯数字，区号和号码间不能有符号</font></td>
		</tr>
        <tr>
            <td class="td1" width="20%">收货人姓名：</td>
            <td><input name="receive_name" id="receive_name" value="<?php echo $this->currc['username']; ?>" /></td>
        </tr>
		<tr>
			<td class="td1" style="text-align:center" colspan="2"><input name="" type="submit" class="btn1" value="提交" /><input name="" type="reset" class="btn1" value="重置" /><?php echo showhide(array_merge($_GET,array('step'=>4))); ?></td>
		</tr>
     </table>
</div>
</form>